<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 构造函数继承
        function Person(name) {
            this.name = name
            this.sleep = function() {
                console.log('睡觉');
            }
        }
        Person.prototype.eat = function() {
            console.log('吃饭');
        }

        function Student(name, score) {
            // 关键步骤
            Person.call(this.name)
            this.score = score
        }
        var s1 = new Student(98)
        s1.sleep()
        s1.eat() // 无法访问父类原型链上的方法和实行
    </script>
</body>

</html>